package com.cw.maintenance;

import java.awt.BorderLayout;
import java.util.Vector;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;

import com.cw.action.panel.DataPanel;
import com.cw.po.Lottery;

public class TextPanel extends DataPanel {

	JTextArea jta = new JTextArea();
	JViewport jv = new JViewport();
	JScrollPane jsp = new JScrollPane(jv);

	public TextPanel(AddDataDialog parent, Lottery lottery) {
		super(parent, lottery);
		setLayout(new BorderLayout());
		jv.add(jta);
		this.add(jsp);
	}

	@Override
	public Vector getData() {
		int rec = jta.getLineCount();
//		lastNqh = getNextQh(lottery, rec);

		String[] lineStr = jta.getText().split("\n");
		int adddata = 0;
		for (String str : lineStr) {
			String line = str.trim();
			if (line.equals("")) {
				continue;
			}
			Vector e = new Vector<String>();
//			e.addElement(lastNqh.get(adddata)[0]);
//			e.addElement(lastNqh.get(adddata)[1]);
			String[] lineNum = line.split(" ");
			for (int i=0;i<lineNum.length;i++) {				
				String num = lineNum[i];
				if(num.trim().equals("")){
					continue;
				}
				if(i<2){
					e.addElement("'"+num+"'");
				}else{
					e.addElement(num);
				}
//				if (!num.trim().equals("")){
//					e.addElement(num);
//				}
			}
			allinsert.addElement(e);
			adddata++;
		}
		return allinsert;
	}

}
